package com.alibaba.cloud.client9093.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * created by wuquan at 05/09/2021
 * ^_^ ^_^
 * 流控规则的 来源 设置
 */
@Component
public class MyCustomOrigin  implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String origin = httpServletRequest.getHeader("origin");

        if ("origin1".equals(origin)) {
            throw new IllegalArgumentException("origin1 不允许来。。。");
        }
        return origin;
    }
}
